<template>
  <div class="page-container">
    <el-card shadow="never" class="search-form-card">
      <el-form class="search-form" inline label-width="75px" label-suffix=":">
        <el-row :gutter="50">
          <el-col :span="8">
            <el-form-item label="审核类型">
              <el-select v-model="searchParams.type" placeholder="请选择">
                <el-option
                  v-for="item in statusOptions"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="状态">
              <el-select v-model="searchParams.status" placeholder="请选择">
                <el-option
                  v-for="item in statusOptions"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="服务名称">
              <el-input v-model="searchParams.name" placeholder="请输入关键字" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item>
              <el-button type="primary">查询</el-button>
              <el-button>重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <el-card shadow="never">
      <el-tabs v-model="activeName">
        <el-tab-pane label="编目审核" name="catalog">
          <catalog @audit="handleAudit" />
        </el-tab-pane>
        <el-tab-pane label="订阅审核" name="subscribe">
          <subscribe @audit="handleAudit" />
        </el-tab-pane>
      </el-tabs>
    </el-card>
    <PublishInterfaceForm ref="PublishInterfaceForm" title="数据服务接口审核" />
    <PublishDatabaseForm ref="PublishDatabaseForm" title="数据服务库表审核" />

    <SubscribeInterfaceForm ref="SubscribeInterfaceForm" title="数据服务接口订阅审核" />
    <SubscribeDatabaseForm ref="SubscribeDatabaseForm" title="数据服务库表订阅审核" />
  </div>
</template>

<script>
import catalog from '@/views/serve-audit/serve/catalog'
import subscribe from '@/views/serve-audit/serve/subscribe'
import PublishInterfaceForm from '../application/publish-audit-form/interfaceForm'
import PublishDatabaseForm from '../application/publish-audit-form/databaseForm'

import SubscribeInterfaceForm from '../application/subscribe-audit-form/interfaceForm'
import SubscribeDatabaseForm from '../application/subscribe-audit-form/databaseForm'
export default {
  components: {
    catalog,
    subscribe,
    PublishInterfaceForm,
    PublishDatabaseForm,
    SubscribeInterfaceForm,
    SubscribeDatabaseForm
  },
  data() {
    return {
      searchParams: {
        date: [],
        status: ''
      },
      statusOptions: [],
      activeName: 'catalog'
    }
  },
  methods: {
    handleAudit(item) {
      if (this.activeName === 'catalog') {
        if (item['资源类型'] === '接口') {
          this.$refs.PublishInterfaceForm.open()
        } else {
          this.$refs.PublishDatabaseForm.open()
        }
      } else {
        if (item['资源类型'] === '接口') {
          this.$refs.SubscribeInterfaceForm.open()
        } else {
          this.$refs.SubscribeDatabaseForm.open()
        }
      }
    }
  }

}
</script>

<style lang="scss" scoped>
.page-container {
  height: 100%;
}
</style>
